/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.designtime.generator.entity.element;

import com.inspur.edp.bff.designtime.generator.VmGeneratorContext;
import com.inspur.edp.bff.designtime.generator.entity.VmEntityGenContext;
import com.inspur.edp.bff.designtime.generator.entity.node.VoNodeGeneratorContext;
import com.inspur.edp.caf.generator.baseInfo.AnnotationInfo;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.cef.api.RefObject;
import com.inspur.edp.cef.designtime.api.element.GspAssociation;
import com.inspur.edp.cef.designtime.api.element.GspElementObjectType;
import com.inspur.edp.cef.generator.entityGenerator.base.elements.AssoPropertyGenerator;
import com.inspur.edp.cef.generator.overall.GenUtils;
import com.inspur.edp.cef.generator.overall.Utils;
import com.inspur.edp.das.commonmodel.IGspCommonElement;
import com.inspur.edp.formserver.viewmodel.GspViewModelElement;

import java.util.ArrayList;

public class VoAssoPropertyGenerator extends AssoPropertyGenerator
{
	private TypeInfo type;
	private String strType;
	private IGspCommonElement refElement;

	public VoAssoPropertyGenerator(IGspCommonElement refElement, GspAssociation association, VoNodeGeneratorContext voNodeGeneratorContext)
	{
		super(refElement,association,voNodeGeneratorContext);
		this.refElement = refElement;
		RefObject<String> tempRef_strType = new RefObject<String>(strType);
		type = Utils.getRefElementType((GspViewModelElement)((refElement instanceof GspViewModelElement) ? refElement : null), association, voNodeGeneratorContext.getEntityGenContext().getCefGenContext());
		strType = tempRef_strType.argvalue;

	}

	@Override
	protected TypeInfo getPropertyType() {
		return new TypeInfo(type.getTypeName());
	}

	@Override
	protected ArrayList<AnnotationInfo> getGetterAttributeList() {
//		if ((type!=null && !type.isEnum()) || refElement.getIsUdt() || refElement.getObjectType() != GspElementObjectType.Enum)
//		{
			return super.getGetterAttributeList();
//		}

	}

//	@Override
//	protected java.util.ArrayList<Ann> GetAttributeList()
//	{
//		if ((type!=null && !type.IsEnum) || RefElement.IsUdt || RefElement.ObjectType != GSPElementObjectType.Enum)
//		{
//			return super.GetAttributeList();
//		}
//		AttributeInfo tempVar = new AttributeInfo();
//		tempVar.AttributeName = JsonConverterAttribute.class.FullName;
//		tempVar.ArgumentList = new java.util.ArrayList<SyntaxNodeOrToken>(java.util.Arrays.asList(new SyntaxNodeOrToken[] { SyntaxFactory.AttributeArgument(SyntaxFactory.TypeOfExpression(TypeUtils.GetTypeSyntax(EnumConvertor.class))) }));
//		return new java.util.ArrayList<AttributeInfo>(java.util.Arrays.asList(new AttributeInfo[] { tempVar }));
//	}
}
